let mysql = require("mysql")
let option = {
    host:"localhost",
    user:"root",
    password:"root",
    database:"hospital"
}

let con = mysql.createConnection(option);
con.connect((err)=>{
    if(err){
        console.log(err)
    }else{
        console.log('连接成功！')
    }
});


function sqlQuery(strSql,arr){
    return new Promise(function(resolve,reject){
        con.query(strSql,arr,(err,results)=>{
            if(err){
                reject(err)
            }
           else{
            resolve(results)
           }
        })
    })
}

module.exports = sqlQuery;